﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using TA.DotNetUtils;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Indexed repeater paging button.
	/// </summary>
	public class RepeaterPageButtonNormal : BaseRepeaterPageButton
	{
		internal RepeaterPageButtonNormal(Repeater repeater)
			: base(repeater)
		{

		}
		/// <summary>
		/// Gets PagerSettings.Normal.
		/// </summary>
		public override PagerElement PagerElement
		{
			get { return this.PagerSettings.Normal; }
		}
		/// <summary>
		/// Gets the assigned index.
		/// </summary>
		public override int Index
		{
			get { return this._index; }
		}
		/// <summary>
		/// Assigns the index to this button.
		/// </summary>
		/// <param name="index"></param>
		public void SetIndex(int index)
		{
			this._index = index;
		}
		/// <summary>
		/// Gets null (because indexed page buttons don't need a class name).
		/// </summary>
		public override string CssClass
		{
			get { return null; }
		}
		/// <summary>
		/// Adds "selected" class if this button's assigned index is the current page index.
		/// </summary>
		/// <param name="writer"></param>
		protected override void AddAttributesToRender(HtmlTextWriter writer)
		{
			base.AddAttributesToRender(writer);

			if (this.Selected)
				writer.AddAttribute(HtmlTextWriterAttribute.Class, "selected");
		}
		int _index;
	}
}